<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="admin/_fragments :: head('博客管理')"></head>
<!--<head th:fragment="head(title)">-->
<!--  <meta charset="UTF-8">-->
<!--  <meta name="viewport" content="width=device-width, initial-scale=1.0">-->
<!--  <title >博客管理</title>-->
<!--  <link rel="stylesheet" href="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.css">-->
<!--  <link rel="stylesheet" href="../static/css/typo.css" th:href="@{/css/typo.css}">-->
<!--  <link rel="stylesheet" href="../static/css/animate.css" th:href="@{/css/animate.css}">-->
<!--  <link rel="stylesheet" href="../static/lib/prism/prism.css" th:href="@{/lib/prism/prism.css}">-->
<!--  <link rel="stylesheet" href="../static/lib/tocbot/tocbot.css" th:href="@{/lib/tocbot/tocbot.css}">-->
<!--  <link rel="stylesheet" href="../static/css/me.css" th:href="@{/css/me.css}">-->
<!--  <link rel="stylesheet" href="../../static/lib/editormd/css/editormd.min.css" th:href="@{/lib/editormd/css/editormd.min.css}">-->

<!--  &lt;!&ndash; 随机语句 &ndash;&gt;-->
<!--  <script src="https://v1.hitokoto.cn/?encode=js&select=%23hitokoto" defer></script>-->
<!--</head>-->
<body class="m-opacity-mini">

  <!--导航-->
  <nav th:replace="admin/_fragments :: nav(1)" ></nav>
<!--  <div class="ui attached pointing menu">-->
<!--    <div class="ui container">-->
<!--      <div class="right menu">-->
<!--        <a href="#" class="item">发布</a>-->
<!--        <a href="#" class="teal active item">列表</a>-->
<!--      </div>-->
<!--    </div>-->
<!--  </div>-->

  <!--中间内容-->
  <div  class="m-container-small m-padded-tb-big">
    <div class="ui container">
      <!--新增操作提示信息-->
      <div class="ui message" th:unless="${#strings.isEmpty(blogMsg)}">
        <i class="close icon"></i>
        <div class="header">提示：</div>
        <p th:text="${blogMsg}"></p>
      </div>

      <form th:action="@{/admin/blogs/search}" method="post" class="ui secondary segment form" >
<!--        <input type="hidden" name="pageInfo" >-->
        <div class="inline fields">
          <div class="field">
            <input type="text" name="title" placeholder="标题" value="" >
          </div>
          <div class="field">
            <div class="ui labeled action input">
              <div class="ui type selection dropdown">
                <input type="hidden" name="typeId">
                <i class="dropdown icon"></i>
                <div class="default text">分类</div>
                <div class="menu" >
                  <div th:each="type : ${types}" class="item" data-value="1" th:data-value="${type.id}" th:text="${type.name}">错误日志</div>
                </div>
              </div>
            </div>

          </div>

          <div class="inline fields">
            <div class="field">
              <div class="ui checkbox">
                <input type="checkbox" id="recommend" name="recommend"  >
                <label for="recommend" style="top: 7px">推荐</label>
              </div>
            </div>
          </div>
          <div class="field">
            <button type="submit" id="search-btn" class="ui mini teal basic button"><i class="search icon"></i>搜索</button>
            <p id="back-btn" class="ui compact button" onclick="back()">back</p>
          </div>
        </div>
      </form>
      <div id="table-container">
        <table th:fragment="blogList" class="ui compact teal table">
          <thead>
          <tr >
            <th ></th>
            <th >标题</th>
            <th >类型</th>
            <th >推荐</th>
            <th >状态</th>
            <th >更新时间</th>
            <th >操作</th>
          </tr>
          </thead>
          <tbody>
          <tr th:each="blog,blogStat : ${pageInfo.list}">
            <td th:utext="${blogStat.count}">1</td>
            <td th:utext="${blog.title}">刻意练习清单</td>
            <td th:utext="${blog.type.name}">认知升级</td>
            <td th:utext="${blog.recommend} ? '是':'否'">是</td>
            <td th:utext="${blog.published} ? '发布':'草稿'">草稿</td>
            <td th:utext="${#dates.format(blog.updateTime,'yyyy-MM-dd HH:mm')}">2017-10-02 09:45</td>
            <td>
              <a th:href="@{/admin/blogs/{id}/toUpdate(id=${blog.id})}" class="ui mini teal basic button">编辑</a>
              <a th:href="@{/admin/blogs/{id}/delete(id=${blog.id})}" class="ui mini red basic button">删除</a>
            </td>
          </tr>
          </tbody>
          <tfoot>
          <tr>
            <th colspan="7">
              <div class="ui mini pagination menu">
                <a th:href="@{/admin/blogs(pageNum=${pageInfo.pageNum}-1)}" class=" item" th:if="${pageInfo.hasPreviousPage}">上一页</a>
                <a th:href="@{/admin/blogs(pageNum=${pageInfo.pageNum}+1)}" class=" item" th:if="${pageInfo.hasNextPage}">下一页</a>
              </div>
              <a th:href="@{/admin/blogs/addBlog}" class="ui mini right floated teal basic button">新增</a>
            </th>
          </tr>
          </tfoot>
        </table>
      </div>

    </div>
  </div>

  <br>
  <br>
  <!--底部footer-->
  <footer th:replace="admin/_fragments :: footer"></footer>


  <!--导入的script-->
  <th:block th:replace="admin/_fragments :: script">
  </th:block>

  <script>
    $('.menu.toggle').click(function () {
      $('.m-item').toggleClass('m-mobile-hide');
    });

    $('.ui.dropdown').dropdown({
      on : 'hover'
    });


    // $('#back-btn').on('click', function() {
    //   // alert(1);
    //   // location.href = "@{/admin/blogs/}";
    //   // alert(2);
    //   // window.location = "/admin/blogs";
    //   // alert(3);
    //   $(location).attr('href', "/blogs")
    //   alert(4);
    //   // back();
    //  });
    function back(){
      // $("#back-btn").load(/*[[@{/admin/blogs/}]]*/"/blogs/");
      $(location).attr('href', "/admin/blogs");
    }


  </script>
</body>
</html>